from rest_framework import serializers
from order.models import CouponModel,UserCoupon,OrderModel,OrderDetial

class CouponSerializer(serializers.ModelSerializer):
    class Meta:
        model = CouponModel
        fields = "__all__"

class UserCouponSerialzer(serializers.ModelSerializer):
    coulist = serializers.SerializerMethodField(read_only=True)
    def get_coulist(self, obj):
        return {"id":obj.coupon.id,"name":obj.coupon.name,"condition":obj.coupon.condition,"price":obj.coupon.price,"start_time":obj.coupon.start_time,"end_time":obj.coupon.end_time}
    class Meta:
        model = UserCoupon
        fields = "__all__"

class OrderSerializer(serializers.ModelSerializer):
    class Meta:
        model = OrderModel
        fields = "__all__"

class OrderDetialSerializer(serializers.ModelSerializer):
    class Meta:
        model = OrderDetial
        fields = "__all__"